import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'dva'
import { Row, Col, Card, Tabs } from 'antd'
import List from './List'
import Search from './searchBottom'
import Header from './header'
import Details from './details'
import Print from './print'
import Detailss from './detailss'

const FileComponent = ({ location, dispatch, fileComponent, loading }) => {
	const { coverDetails,codeNumber,printInfo,printDetails,list, showDetails, details, params, menu, isComponent, userList, pagination, depTypes, showDashborad, showDetailsList,applyUser } = fileComponent
	// console.log(params)
	// console.log(pagination)
	// console.log(menu)
	const listProps = {
		list,
		pagination,
		menu,
		showDet(payload) {
			dispatch({
				type: 'fileComponent/showDet',
				payload: {
					...payload
				}
			})
		},
		showDet1(payload) {
			dispatch({
				type: 'fileComponent/showDet1',
				payload: {
					...payload
				}
			})
		},
		isFileComponent(name) {
			dispatch({
				type: 'fileComponent/isFileComponent',
				payload: name
			})
		},
		onComponent(payload) {
			dispatch({
				type: 'fileComponent/applicationSave',
				payload: {
					...payload
				}
			})
		},
		onPageChange(page) {
			const { query, pathname } = location
			dispatch({
				type: 'fileComponent/searchList',
				payload: {
					...params,
					page: page.current,
					pageSize: page.pageSize,

					//              	  type:params.type,  //档案类型
					//				  businessType:params.businessType,  //业务类型
					//				  createUser:params.createUser,  //管理人
					//				  title:params.title,   //档案标题
					//				  startTime:params.strTime,  //开始时间
					//				  endTime:params.endTime,    //结束时间
					//				  auditState:params.auditState,  //档案状态
					//				  operatingState:menu,   //0申请  1审批  2我提交的  3已审批 
					//				  operatingType:0,  //0归档  1变更  2销毁
				}
			})
		},
		getCover(payload){
			dispatch({
				type: 'fileComponent/getCoverInfo',
				payload: {
					...payload
				}
			})
		}
	}
	const detailsProps = {
		coverDetails,
		details,
		isComponent,
		userList,
		depTypes,
		showList() {
			dispatch({
				type: 'fileComponent/showList',
				payload: {}
			})
		},
		onEdit(payload) {
			dispatch({
				type: 'fileComponent/applicationUpdate',
				payload: {
					...payload
				}
			})
		},
		updateFile(payload) {
			dispatch({
				type: "fileComponent/update",
				payload: {
					...payload
				}
			})
		},
		updateFile1(payload) {
			dispatch({
				type: "fileComponent/update1",
				payload: {
					...payload
				}
			})
		},
		goPrint1(payload){
			dispatch({
				type:"fileComponent/goPrint1",
				payload:{
					...payload
				}
			})
		}
	}
	const detailsProps1 = {
		coverDetails,
		details,  
		isComponent, 
		// userList,
		// depTypes,
		showList() {  
			dispatch({
				type: 'fileComponent/showList',
				payload: {}
			})
		},
		onEdit(payload) { 
			dispatch({
				type: 'fileComponent/applicationUpdate',
				payload: {
					...payload
				}
			})
		},
		// updateFile(payload) {
		// 	dispatch({
		// 		type: "fileComponent/update",
		// 		payload: {
		// 			...payload
		// 		}
		// 	})
		// },
		// updateFile1(payload) {
		// 	dispatch({
		// 		type: "fileComponent/update1",
		// 		payload: {
		// 			...payload
		// 		}
		// 	})
		// },
		// goPrint1(payload){
		// 	dispatch({
		// 		type:"fileComponent/goPrint1",
		// 		payload:{
		// 			...payload
		// 		}
		// 	})
		// }
	}	
	const headerProps = {
		menu,
		pagination,
		showMenu(id) {
			dispatch({
				type: 'fileComponent/showMenu',
				payload: id
			})
		},
		onSearch(params1) {
			dispatch({
				type: 'fileComponent/searchList',
				payload: {
					...params1
				}
			})
		},
	}
	const searchProps = {
		menu,
		userList,
		onSearch(params1) {
			dispatch({
				type: 'fileComponent/searchList',
				payload: {
					...params1
				}
			})
		},
	}
	const printProps = {
		printDetails,
		userList,
		printInfo,
		codeNumber,
		applyUser,
		showList(){
			dispatch({
				type:"fileComponent/showLists1"
			})
		},
		goList(){
			dispatch({
				type:"fileComponent/showLists"
			})
		},
		getCode(){
			dispatch({
				type:"fileComponent/getCodeNumber"
			})
		},
		newCover(params){
			dispatch({
				type:"fileComponent/newCover",
				payload:{
					...params
				}
			})
		},
		updateCover(params){
			dispatch({
				type:"fileComponent/updateCover",
				payload:{
					...params
				}
			})
		}
	}

	return (
		<div className="content-inner" style={{ backgroundColor: 'transparent', padding: 0 }}>
			<div style={{ display: showDashborad ? 'block' : 'none' }}>
				<Print {...printProps}/>
			</div>
			<div style={{ display: showDashborad ? 'none' : 'block' }}>
				<div style={{ display: showDetails || showDetailsList? 'none' : 'block' }}>
					<Header {...headerProps} />
					{ menu == 0 ?
						<Search {...searchProps} />:""
					}
					
					<List {...listProps} />
				</div>
				<div style={{ display: showDetails ? 'block' : 'none' }}>
					{showDetails && <Details {...detailsProps} />}
				</div>
				<div style={{ display: showDetailsList ? 'block' : 'none' }}>
					<Detailss {...detailsProps1} />
				</div>
			</div>
		</div>
	)
}

export default connect(({ fileComponent, loading }) => ({ fileComponent, loading }))(FileComponent)
